package com.demo.example.proxy.cglib;

import org.springframework.cglib.proxy.Callback;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.NoOp;

public class Client {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(UserService.class);
        // 设置增强类数组
        enhancer.setCallbacks(new Callback[]{new LogInterceptor(), new CheckInterceptor(), NoOp.INSTANCE});
        // 设置增强类过滤器
        enhancer.setCallbackFilter(new InterceptorFilter());

        UserService proxy = (UserService) enhancer.create();
        proxy.select();
        System.out.println();
        proxy.update();
    }
}
